package com.sec.android.app.myfiles.shadow.android;

import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;

import com.sec.android.app.myfiles.info.AppConstants;

import org.powermock.api.mockito.PowerMockito;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jaebae on 2016-07-01.
 */
@Implements(StorageManager.class)
public class ShadowStorageManager {
    public static ArrayList<StorageVolume> sStorageVolumes = new ArrayList<>();
    public static ArrayList<String> sPath = new ArrayList<>();

    static {
        addDefaultStorageVolumes();
    }

    public static void addDefaultStorageVolumes() {
        addStorageVolumes(AppConstants.StoragePath.INTERNAL_ROOT);
    }

    public static void addStorageVolumes(String path) {
        sStorageVolumes.add(PowerMockito.mock(StorageVolume.class));
        sPath.add(path);
    }

    public static void clearStorageVolumes() {
        sStorageVolumes.clear();
        sPath.clear();
        addDefaultStorageVolumes();
    }


    public static List<StorageVolume> getStorageVolumes() {
        return sStorageVolumes;
    }

    public static String getVolumePath(StorageVolume volume) {
        int index = ShadowStorageManager.sStorageVolumes.indexOf(volume);
        return ShadowStorageManager.sPath.get(index);
    }


    @Implementation
    public String getVolumeState(String mountPoint) {
        return "mounted";
    }
}
